3D Graphics Programming with QuickDraw 3D 1.5.4
Previous | QD3D Book | Overview | Chapter Contents | Next |
When a model includes a mesh, you can decide whether the entire mesh only or parts of the mesh also are eligible for picking. You do this by specifying an appropriate hit information mask. For example, to allow mesh parts to be selected, you can set up the hit information mask like this:
myPickData.mask = kQ3PickDetailMaskShapePart |
kQ3PickDetailMaskObject |
kQ3PickDetailMaskDistance;
This line of code indicates that you want QuickDraw 3D to return information about objects and any distinguishable parts of objects, as well as the distances from the objects to the pick origin. (To prevent mesh parts from being selected, you simply omit adding in the kQ3PickDetailMaskShapePart mask.)
You can determine whether data returned by Q3Pick_GetPickDetailData applies to a shape part by inspecting the validMask bit. If the value of the bit is 1, the data contains information about a shape part. Currently the only available shape parts are mesh parts. Listing 6 illustrates how to use the shapePart field to determine the type of mesh part selected and to perform some operation on the selected mesh part.
Q3Pick_GetPickDetailValidMask(myPickObject, myIndex);
Q3Pick_GetPickDetailData(myPickObject, myIndex, shapePart);
if (shapePart != NULL) {
switch(Q3Object_GetLeafType(shapePart)) {
case kQ3MeshPartTypeMeshFacePart:
Q3MeshFacePart_GetFace(shapePart, &myFace);
MyDoPickFace(object, myFace);
break;
case kQ3MeshPartTypeMeshEdgePart:
Q3MeshEdgePart_GetEdge(shapePart, &myEdge);
MyDoPickEdge(object, myEdge);
break;
case kQ3MeshPartTypeMeshVertexPart:
Q3MeshVertexPart_GetVertex(shapePart, &myVertex);
MyDoPickVertex(object, myVertex);
break;
}
}
This code branches on the type of the mesh part indicated by the shapePart field. For each defined type of mesh part, the code calls a QuickDraw 3D routine to retrieve the corresponding mesh face, edge, or vertex. Then it calls an application-defined routine (for example, MyDoPickFace ) to handle the mesh part selection.
Previous | QD3D Book | Overview | Chapter Contents | Next |